class Behavior3 extends egret.Sprite {
    private tree:b3.BehaviorTree
    private target:any
    private blackboard:b3.Blackboard
    public constructor() {
        super()
        console.log("Hello World", b3.VERSION)
        this.tree = new b3.BehaviorTree()
        this.tree.root = new b3.MemSequence({
            children: [
                new Log("Hello"),
                new b3.Wait({milliseconds:3000}),
                new Log("World")
            ]
        })
        this.target = {}
        this.blackboard = new b3.Blackboard()
        
        //创建一个计时器对象
        let timer:egret.Timer = new egret.Timer(500, 0)
        //注册事件侦听器
        timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this)
        //开始计时
        timer.start()
    }

    private timerFunc() {
        console.log("timerFunc")
        this.tree.tick(this.target, this.blackboard)
    }
}

class Log extends b3.Action {
    public constructor(text:string) {
        super({
            name: 'Log',
            title: 'Log Text',
            properties: {text:text}
        })
    }

    public tick() {
        console.log(this.properties.text)
        return b3.SUCCESS
    }
}